#ifndef __ACCUMULATE_H__
#define __ACCUMULATE_H__

#include <vector>
using namespace std;

#include "apixel.h"

class ASTAR_TRANSFORM;

class ACCUMULATOR
{
	int m_height;
	int m_width;
	ACCUM_PIXEL **m_image;

	public:

	class iterator
	{

		public:
		ACCUM_PIXEL *p;

		bool operator !=( const iterator &a ) { return p != a.p; }
		bool operator ==( const iterator &a ) { return p == a.p; }
		ACCUM_PIXEL &operator *(void) { return *p; }
		iterator &operator ++( void  ) { p++; return *this; }
	};

	class const_iterator
	{

		public:
		ACCUM_PIXEL *p;

		bool operator !=( const const_iterator &a ) { return p != a.p; }
		bool operator ==( const const_iterator &a ) { return p == a.p; }
		const ACCUM_PIXEL &operator *(void) { return *p; }
		const_iterator &operator ++( void  ) { p++; return *this; }
	};


	ACCUMULATOR( void );
	~ACCUMULATOR( void );

	void alloc_image( int width, int height );
	void free_image( void );
	void get_dim( int &width, int &height ) const;

	iterator begin( void );
	iterator end( void );
	const_iterator const_begin( void ) const;
	const_iterator const_end( void ) const;

	void rotate_and_add( const AIMAGE &frame, ASTAR_TRANSFORM &t );
	void rotate_and_sub_dark( const AIMAGE &frame, ASTAR_TRANSFORM &t );
	void to_image( AIMAGE &dst );
	void normalize();
	void sum_of_square( const ACCUMULATOR &frame, const ACCUMULATOR &normals );
	void cls();
};

#endif

